var survey_version=-1;

function commit_asks() {
	var nickname=document.getElementById("nickname").value;
	var email=document.getElementById("email").value;
	var isused;
	if(document.getElementsByName("isused")[0].checked==true){
		//alert("isused=true");
		isused=true;
	}else if(document.getElementsByName("isused")[1].checked==true){
		//alert("isused=false");
		isused=false;
	}else{
		alert("请告诉我们您是否使用了我们的产品！\nPlease tell us whether you use our products!");
		return ;
	}
	var satisfaction=document.getElementById("satisfaction").value;
	//alert(satisfaction);
	var issatis;
	if(document.getElementsByName("issatis")[0].checked==true){
		//alert("issatis=true");
		issatis=true;
	}else if(document.getElementsByName("issatis")[1].checked==true){
		//alert("issatis=false");
		issatis=false;
	}else{
		alert("请告诉我们您是否对学校提供的信息化技术满意！\nPlease tell us that do you satisfactory for the information technology which your school provides!");
		return ;
	}
	var isprospect;
	if(document.getElementsByName("isprospect")[0].checked==true){
		//alert("isprospect=true");
		isprospect=true;
	}else if(document.getElementsByName("isprospect")[1].checked==true){
		//alert("isprospect=false");
		isprospect=false;
	}else{
		alert("请告诉我们您是否认为集成信息化服务在学校中有前景！\nPlease tell us whether you think the integrated information service promising in the school!");
		return ;
	}
	var functions=document.getElementById("functions").value;
	//alert(functions);
	var where=document.getElementById("where").value;
	var willask;
	if(document.getElementsByName("willask")[0].checked==true){
		//alert("willask=true");
		willask=true;
	}else if(document.getElementsByName("willask")[1].checked==true){
		//alert("willask=false");
		willask=false;
	}else{
		alert("请告诉我们你是否愿意继续接受追访！\nPlease tell us if you would like to continue to receive attention!");
		return ;
	}
	//alert(isused);
	//alert(issatis);
	//alert(willask);
	
	var json_data="{\"version\":\""+survey_version+"\""+",\"content\":[";
	json_data+="{\"name\":\"nickname\,\"content\":\""+nickname+"\"},";
	json_data+="{\"name\":\"email\",\"content\":\""+email+"\"},";
	json_data+="{\"name\":\"isused\",\"content\":\""+isused+"\"},";
	json_data+="{\"name\":\"satisfaction\",\"content\":\""+satisfaction+"\"},";
	json_data+="{\"name\":\"issatis\",\"content\":\""+issatis+"\"},";
	json_data+="{\"name\":\"isprospect\",\"content\":\""+isprospect+"\"},";
	json_data+="{\"name\":\"functions\",\"content\":\""+functions+"\"},";
	json_data+="{\"name\":\"where\",\"content\":\""+where+"\"},";
	json_data+="{\"name\":\"willask\",\"content\:\""+willask+"\"}";
	json_data+="]}";
	//alert(json_data);
	
	if(confirm("确定提交？我们可能会收集一些关于您的匿名信息，请允许！\nDetermine submission? We may collect anonymous information about you, please allow!")==true){
		var ajax=new XMLHttpRequest();
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4 && ajax.status==200){
				if(ajax.responseText=="succes"){
					alert("提交成功！感谢您的帮助！\nSubmitted to the success! Thanks for your help.");
					//window.location="../index.html";
				}else{
					alert("提交失败！请重试！下方将给出详细信息。\nFailed to commit! Please try again! The details are given below.\n"+ajax.responseText);
				}
			}
		};
		ajax.open("POST", "../../BreaThingServer/SurveyCommit", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send("json_content="+json_data);
	}else{
		alert("提交已取消！\nSubmission is cancel!")
	}
}
